package org.example;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2025-01-14
 * Time: 16:35
 */
public class demo1 {
    public static void main(String[] args) {

        try {
            //1.加载数据库厂商提供的驱动
            Class.forName("com.mysql.cj.jdbc.Driver");
            //2.获取数据库连接
            Connection connection=DriverManager.getConnection("jdbc :mysql://127.0.0.1:3306/test?characterE" +
                    "ncoding=utf8&allowPublicKeyRetrieval=true&usessL=false","root","Zss.zss123");
            //3.创建ststement对象
            Statement statement = connection.createStatement();
            //4.定义SQL并执行SQL

        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
